import { instance, unwrap } from './utils'

export async function listAddrs(params?: API.PageReq) {
  return unwrap(await instance.post<API.Res<Data[]>>('/car/userAddress/getUserAddressList', null, { params }))
}

export async function getAddr(id: number | string) {
  return unwrap(await instance.post('/car/userAddress/getUserAddressById', null, { params: { id } }))
}

export async function createAddr(data: API.Req) {
  return unwrap(await instance.post('/car/userAddress/addUserAddress', data))
}

export async function updateAddr(data: API.Req) {
  return unwrap(await instance.post('/car/userAddress/editUserAddress', data))
}

export async function deleteAddr(id: number) {
  return unwrap(await instance.post('/car/userAddress/removeUserAddressById', null, { params: { id } }))
}
